package com.example.lanouhn.firstapp.activity.utils;

import com.alibaba.fastjson.JSON;
import com.example.lanouhn.firstapp.activity.model.CollectionStore;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lanouhn on 16/8/4.
 */
public class CollectionStoreJson {
    public static List<CollectionStore> getCollectionStore(String json){
        List<CollectionStore> list = new ArrayList<>();

        try {
            JSONObject job = new JSONObject(json);

            String data = job.getString("datas");

            JSONObject jsonObject = new JSONObject(data);

            JSONArray array = jsonObject.getJSONArray("favorites_list");
            //使用fast解析
           list = new ArrayList<>(JSON.parseArray(array.toString(),CollectionStore.class));

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return list;
    }
}
